<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Title</title>
</head>
<body>

</body>
<script>
	// 1- 字面量
	// const obj = {}
	
	// 2- 通过工厂模式
	// function createObj(userName,age){
	// 	return {
	// 		userName,
	// 		age
	// 	}
	// }
	// const obj = createObj("zhangsan",12)
	// const obj2 = createObj("lisi",12);
	
	// 3- Object
	// const obj = new Object({
	// 	userName:"zhangsan",
	// 	age:12
	// })
	// console.log(obj);
	
	// 4- 构造函数
	// function Box(userName,age){
	// 	this.userName = userName;
	// 	this.age = age;
	// }
	// const Box = function(userName,age){
	// 	this.userName = userName;
	// 	this.age = age;
	// }
	// const obj = new Box("zhangsan",12);
	// console.log(obj);
	
	// 5- class
	class Box1{
		constructor(userName,age) {
			this.userName = userName;
			this.age = age;
		}
	}
	const Box2 = class{
		constructor(userName,age) {
			this.userName = userName;
			this.age = age;
		}
	}
	console.log(new Box1("zhangsan",12))
	console.log(new Box2("lisi",18))
</script>
</html>